package com.kaifamiao.demo.d0725.pm;

import java.util.Scanner;

public class Test03 {

    public static void main(String[] args) {
        Person me = new Person();
        Person obj = new Person();
//        Person[] persons = {me, obj}; // 对象数组
//        for(int i = 0; i < persons.length; i ++){
//            persons[i].name = inputString("请输入姓名：");
//            persons[i].gender = inputChar("请输入性别：");
//            persons[i].age = inputInt("请输入年龄：");
//            persons[i].isMarry = inputBoolean("是否已婚？");
//            persons[i].show();
//        }
//        String name = inputString("请输入姓名：");
//        me.name = name;

        // 自己的属性
        me.name = inputString("请输入姓名：");
        me.gender = inputChar("请输入性别：");
        me.age = inputInt("请输入年龄：");
        me.isMarry = inputBoolean("是否已婚？");
        me.show();



        // 对象的属性
        obj.name = inputString("请输入姓名：");
        obj.gender = inputChar("请输入性别：");
        obj.age = inputInt("请输入年龄：");
        obj.isMarry = inputBoolean("是否已婚？");

        obj.show();

        if (me.canMarry(obj)){
            System.out.println(me.name + " 能和 " + obj.name + "结婚，恭喜");
        } else {
            System.out.println(me.name + " 不能和 " + obj.name + "结婚, 请注意！！");
        }
    }

    static Scanner sc = new Scanner(System.in);

    public static String inputString(String msg){
        System.out.println(msg);
        return sc.next();
    }

    public static char inputChar(String msg){
        System.out.println(msg);
        return sc.next().charAt(0);
    }

    public static int inputInt(String msg){
        System.out.println(msg);
        return sc.nextInt();
    }

    public static boolean inputBoolean(String msg){
        System.out.println(msg);
        return sc.nextBoolean();
    }
}
